//
// Created by NASA on 2023/12/2.
//

#include <iostream>

using namespace std;

int main()
{
    int a,b,y=1;
    cin>>a>>b;
    while(y>0)
    {
        y=a%b;
        if(y>0)
        {
            a=b;
            b=y;
        }
    }
    cout<<b;
    return 0;
}